// 防抖
export default {
  data() {
    return {
      debounceTimer: null,
      isfullscreen: false,
      dialogWidth: ''
    }
  },
  mounted() {
    this.tableBoxdoLayout()
  },
  methods: {
    $debounce(func, ...args) {
      const context = this
      if (this.debounceTimer) clearTimeout(this.debounceTimer)
      const callNow = !this.debounceTimer // 是否立即执行
      this.debounceTimer = setTimeout(() => {
        this.debounceTimer = null
      }, 900)
      if (callNow) func.apply(context, args)
    },
    resetSize(px) { // echarts动态改变字体大小 传入字体大小
      const clientWidth = window.innerWidth || document.body.clientWidth // 屏幕尺寸
      if (!clientWidth) { return 0 }
      const fontSize = clientWidth / 1920
      const count = px * fontSize
      if (count < px) {
        return px
      }
      return count
    },
    updataFull(newValue) { // 控制全屏
      this.isfullscreen = newValue
    },
    setDialogWidth(ww) { // 设置弹窗宽度
      return this.dialogWidth || ww
    },
    updataDialogWidth(width) { // 拖动弹窗右下角改变弹窗宽度
      this.dialogWidth = width + 'px'
    },
    tableBoxdoLayout() {
      this.$nextTick(() => {
        this.$refs.tableBox && this.$refs.tableBox.$watch(
          'bodyWidth',
          () => {
            this.$refs.tableBox.doLayout()
          }
        )
      })
    }
  }
}
